package cn.assumejson.springframework.beans.context.support;

import cn.assumejson.springframework.beans.context.ApplicationContext;
import cn.assumejson.springframework.beans.factory.BeansException;
import lombok.extern.slf4j.Slf4j;

/**
 * 封装了 Reader BeanFactory 所有的方法
 *
 * @author Mr. Li
 * @version 1.0
 * @since 1.0 2021/11/30 16:01
 */
@Slf4j
public class ClassPathXmlApplicationContext extends AbstractXmlApplicationContext {

    /**
     * 根据给定的源数据加载
     *
     * @param configLocation xml
     * @throws BeansException
     */
    public ClassPathXmlApplicationContext(String configLocation) throws BeansException {
        this(new String[]{configLocation}, true, null);
    }

    public ClassPathXmlApplicationContext(
            String[] configLocations, boolean refresh, ApplicationContext parent)
            throws BeansException {

        super(parent);
        setConfigLocations(configLocations);
        if (refresh) {
            log.info("Container ready to refresh ");
            refresh();
        }
    }
}
